Simple data items like dates, numbers and strings may have different representations that are used in different programming environments. Such representations may define various characteristics that relate to the way the data item is used in a particular programming environment. For example, such representations may define semantically meaningful characteristics, such as precision, as well as semantically invisible characteristics, such as performance.
As is known in the art, a scripting environment may be hosted within another programming environment, which may be referred to as the host environment. The host environment may comprise, for example and without limitation, a programming environment associated with a Web browser, operating system, game application, or enterprise application. A script that is written for execution by the hosted scripting environment may refer to a data item that is to be obtained from and/or returned to the host environment and that has a well-defined representation that is semantically meaningful within the context of the scripting environment. However, the representation of the data item used by the host environment may be different than that used by the scripting environment.
Traditionally, two solutions have been used to address the issue of differing host environment and scripting environment representations. In accordance with the first solution, when interface logic of the host is marshaling the data item to and from the scripting environment, the interface logic converts between the two different representations. However, such conversion can result in the loss of semantically meaningful information and can also adversely impact the performance of the computing platform upon which the different environments are executing. In accordance with the second solution, additional distinct data types are created for each of the different representations and exposed to the developer, along with user-available bridges for facilitating manual conversions. However, this approach requires the developer to learn and manage new data types that are not normally associated with the scripting environment. Furthermore, scripts that are written to reference the new data types will not be executable by scripting environments that haven't been modified to recognize them, thereby limiting the reusability/portability of such scripts.